import { Injectable } from '@angular/core';
import {Observable} from 'rxjs/Rx';
import {FormUtil} from '../../../util/form-util';
import {DaAPI} from '../da-constants';
import {RequestUtil} from '../../../util/request-util';
import {MsgResult} from '../../../models/msg-result';

@Injectable()
export class DaClassifiedService {
  constructor(
    private requestUtil: RequestUtil,
    private formUtil: FormUtil
  ) { }
  /**
   * 获取站点数据
   * @returns {Observable<MsgResult>}
   */
  getSiteData(): Observable<MsgResult> {
    const params = 'siteTypeCode=400' + '&monitorCode=' + "'VOCS'";
    return this.requestUtil.get(DaAPI.getSiteData, params);
  }

  /**
   * 获取分类统计
   * @returns {Observable<MsgResult>}
   */
  getClassifyData(dataObj): Observable<MsgResult> {
    const params =  this.formUtil.serialize(dataObj);
    return this.requestUtil.post(DaAPI.vocComData, params);
  }

  /**
   * 获取分类统计占比
   * @returns {Observable<MsgResult>}
   */
  getRatioData(dataObj): Observable<MsgResult> {
    const params =  this.formUtil.serialize(dataObj);
    return this.requestUtil.get(DaAPI.vocComData, params);
  }
  /**
   * 获取vocs分类数据
   * @returns {Observable<MsgResult>}
   */
  getVocClassData(): Observable<MsgResult> {
    return this.requestUtil.get(DaAPI.vocClassData);
  }

  /**
   * 获取分类统计占比
   * @returns {Observable<MsgResult>}
   */
  getClassifieRatioData(dataObj): Observable<MsgResult> {
    const params =  this.formUtil.serialize(dataObj);
    return this.requestUtil.post(DaAPI.vocComRatioData, params);
  }
}
